home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Draw Editor / Source / DrawEditorUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-11  |  7.2 KB  |  287 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SamplePartUtils.h
  3.  
  4.     Contains:    SamplePart utility functions & classes
  5.  
  6.     Written by:    Adapted from SamplePartUtils.cpp and enhanced by Dave Stafford.
  7.  
  8.     Copyright:    © 1994,95 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11.  
  12. #ifndef _DRAWPARTPARTUTILS_
  13. #define _DRAWPARTPARTUTILS_
  14.  
  15. #ifndef _SAMPLECOLLECTIONS_
  16. #include "SampleCollections.h"
  17. #endif
  18.  
  19. // --- OpenDoc Includes ---
  20.  
  21. #ifndef _ODTYPES_
  22. #include <ODTypes.h>
  23. #endif
  24.  
  25. #ifndef SOM_ODFacet_xh
  26. #include <Facet.xh>
  27. #endif
  28.  
  29. #ifndef SOM_ODShape_xh
  30. #include <Shape.xh>
  31. #endif
  32.  
  33. #ifndef SOM_ODStorageUnitView_xh
  34. #include <SUView.xh>
  35. #endif
  36.  
  37. #ifndef SOM_ODWindow_xh
  38. #include <Window.xh>
  39. #endif
  40.  
  41. // --- OpenDoc Public Utilities ---
  42.  
  43. #ifndef _ITEXT_
  44. #include <IText.h>
  45. #endif
  46.  
  47. // --- Macintosh Includes ---
  48.  
  49. #ifndef __TYPES__
  50. #include <Types.h>
  51. #endif
  52.  
  53.  
  54. //------------------------------------------------------------------------------
  55. // DrawEditor Specific Macros
  56. //------------------------------------------------------------------------------
  57. #define UNUSED(x)    ((void) &x)
  58.  
  59. //------------------------------------------------------------------------------
  60. // DrawEditor Specific Utilities
  61. //------------------------------------------------------------------------------
  62.  
  63. // --- Misc
  64. void             SetMenuItemText( Environment* ev, ODID menuID, ODID menuItem );
  65. ODSShort         StrToShort( StringPtr pstr );
  66. void             NumToString( ODSShort number, char* result );
  67. ODBoolean        RectContainsRect(Rect& rect, Rect& inside);
  68.  
  69. // --- Shapes
  70. ODBoolean        IsValidRect( Rect& rect );
  71. void             SortRect( Rect* rect );
  72. void             MapRect( Rect& src1, Rect& src2, Rect* dest );
  73. void             InspectShape( Environment* ev, ODShape* shape );
  74.  
  75. // --- Imaging
  76. void            ChangeFacetHighlight(Environment* ev, 
  77.                                         ODFacet* changeFacet, 
  78.                                         ODHighlight newHighlight);
  79.  
  80. // --- D&D
  81. void             HiliteFacet( Environment* ev, ODDragAndDrop* dad, 
  82.                                 ODFacet* facet, ODBoolean show);
  83.  
  84. // --- Interchange
  85. ODBoolean             ValueOnClipboard(Environment *ev, ODValueType type, 
  86.                                     ODSession* session);
  87. void                 ResolveClipboardPromises(Environment *ev, ODSession* session);
  88. void                 CheckAndResolvePromisedShapes(Environment *ev, 
  89.                                             COrderedList* shapeList, 
  90.                                             ODSession* session);
  91.  
  92. // --- Resources
  93. PicHandle             ODLoadPicture(ODSShort id);
  94. void                 ODDeletePicture(PicHandle thePicture);
  95.  
  96. //------------------------------------------------------------------------------
  97. // StorageUnit I/O
  98. //------------------------------------------------------------------------------
  99.  
  100. void        StorageUnitSetISOStrValue(    ODStorageUnit* su,
  101.                                         Environment* ev, 
  102.                                         ODISOStr value);
  103.                                         
  104. ODISOStr    StorageUnitGetISOStrValue(     ODStorageUnit* su,
  105.                                         Environment* ev);
  106.  
  107.  
  108. //------------------------------------------------------------------------------
  109. // Function Prototypes
  110. //------------------------------------------------------------------------------
  111.  
  112. void            SetPartName(Environment* ev, ODPart* part, ODIText* partName);
  113. void            GetEditorScriptLanguage(Environment* ev, ODScriptCode* script,
  114.                                         ODLangCode* language);
  115. void            FixedToIntRect(ODRect& fixedRect, Rect& intRect);
  116. void            IntToFixedRect(Rect& intRect, ODRect& fixedRect);
  117. void            LoadIcons(Environment* ev, ODUShort whichSuite, Handle* suite);
  118. void            LoadThumbnail(Environment* ev, Handle* thumbnail);
  119. Rect            TilePartWindow(Environment* ev, Rect* facetBounds,
  120.                                         Rect* partWindowBounds);
  121. ODUShort        CountFramesFacets(Environment* ev, ODFrame* frame);
  122.                                         
  123. //------------------------------------------------------------------------------
  124. // Utility Class Definitions
  125. //------------------------------------------------------------------------------
  126.  
  127. class CCloneInfo 
  128. {
  129. public:
  130.     CCloneInfo(ODDraftKey key, 
  131.                 ODDraft* fromDraft, 
  132.                 ODFrame* scopeFrame, 
  133.                 ODCloneKind kind  );
  134.     ~CCloneInfo();
  135.     
  136.     // Key returned from draft when clone is initiated, it is used when
  137.     // referencing the cloning operation
  138.     ODDraftKey         fKey; 
  139.     
  140.     // Source of clone            
  141.     ODDraft*         fFromDraft; 
  142.     
  143.     // This is the containing scope of the clone operation
  144.     // could be either destination or source.            
  145.     ODFrame*         fScopeFrame;
  146.     
  147.     // The type of clone operation, specified at time of clone
  148.     // and used by OpenDoc            
  149.     ODCloneKind        fCloneKind;
  150.     
  151. };
  152.  
  153. class CFrameInfo
  154. {
  155.     public:
  156.             CFrameInfo();
  157.             ~CFrameInfo();
  158.     
  159.     void    Externalize(Environment* ev, ODStorageUnitView* storageUnitView);
  160.     void    CleanseFrameInfoProperty(Environment* ev, ODStorageUnit* storageUnit);
  161.     void    ExternalizeFrameInfo(Environment* ev, ODStorageUnit* storageUnit,
  162.                                     ODDraftKey key, ODFrame* scopeFrame);
  163.     void    CloneInto(Environment *ev, ODDraftKey key,
  164.                                     ODStorageUnitView* storageUnitView,
  165.                                     ODFrame* scopeFrame);
  166.     void    InitFromStorage(Environment* ev, ODStorageUnitView* storageUnitView);
  167.                 
  168.     ODBoolean        IsFrameActive();
  169.     void            SetFrameActive(ODBoolean active);
  170.     ODBoolean        FrameNeedsReactivating();
  171.     void            SetFrameReactivate(ODBoolean reactivate);
  172.     ODFacet*        GetActiveFacet();
  173.     void            SetActiveFacet(ODFacet* facet);
  174.     void            SetSourceFrame(Environment* ev, ODFrame* sourceFrame);
  175.     ODFrame*        GetSourceFrame();
  176.     void            ReleaseSourceFrame(Environment* ev);
  177.     ODBoolean        HasSourceFrame();
  178.     ODWindow*        GetPartWindow();
  179.     ODBoolean        HasPartWindow();
  180.     void            SetPartWindow(ODWindow* window);
  181.     void            AttachFrame(Environment* ev, ODFrame* frame);
  182.     void            DetachFrame(Environment* ev);
  183.     ODFrame*        GetAttachedFrame();
  184.     ODBoolean        HasAttachedFrame();
  185.     void            SetShouldDisposeWindow(ODBoolean should);
  186.     ODBoolean        ShouldDisposeWindow();
  187.     
  188.     private:
  189.     
  190.     ODBoolean        fFrameActive;
  191.     ODBoolean        fFrameReactivate;
  192.     ODBoolean        fShouldDisposeWindow;
  193.     ODFacet*        fActiveFacet;
  194.     ODFrame*        fSourceFrame;
  195.     ODFrame*        fAttachedFrame;
  196.     ODWindow*        fPartWindow;
  197. };
  198.  
  199.  
  200.  
  201.  
  202. //-------------------------------------------------------------------------
  203. // Inline methods
  204. //-------------------------------------------------------------------------
  205.  
  206. //=========================================================================
  207. // CFrameInfo
  208. //=========================================================================
  209.  
  210. inline ODBoolean CFrameInfo::IsFrameActive()
  211. {
  212.     return fFrameActive;
  213. }
  214.  
  215. inline void CFrameInfo::SetFrameActive(ODBoolean active)
  216. {
  217.     fFrameActive = active;
  218. }
  219.  
  220. inline ODBoolean CFrameInfo::FrameNeedsReactivating()
  221. {
  222.     return fFrameReactivate;
  223. }
  224.  
  225. inline void CFrameInfo::SetFrameReactivate(ODBoolean reactivate)
  226. {
  227.     fFrameReactivate = reactivate;
  228. }
  229.  
  230. inline ODFacet* CFrameInfo::GetActiveFacet()
  231. {
  232.     return fActiveFacet;
  233. }
  234.  
  235. inline void CFrameInfo::SetActiveFacet(ODFacet* facet)
  236. {
  237.     fActiveFacet = facet;
  238. }
  239.  
  240. inline ODFrame* CFrameInfo::GetSourceFrame()
  241. {
  242.     return fSourceFrame;
  243. }
  244.  
  245. inline ODBoolean CFrameInfo::HasSourceFrame()
  246. {
  247.     return (fSourceFrame != kODNULL);
  248. }
  249.  
  250. inline ODWindow* CFrameInfo::GetPartWindow()
  251. {
  252.     return fPartWindow;
  253. }
  254.  
  255. inline ODBoolean CFrameInfo::HasPartWindow()
  256. {
  257.     return (fPartWindow != kODNULL);
  258. }
  259.  
  260. inline void CFrameInfo::SetPartWindow(ODWindow* window)
  261. {
  262.     fPartWindow = window;
  263. }
  264.  
  265. inline ODFrame* CFrameInfo::GetAttachedFrame()
  266. {
  267.     return fAttachedFrame;
  268. }
  269.  
  270. inline ODBoolean CFrameInfo::HasAttachedFrame()
  271. {
  272.     return (fAttachedFrame != kODNULL);
  273. }
  274.  
  275. inline void CFrameInfo::SetShouldDisposeWindow(ODBoolean should)
  276. {
  277.     fShouldDisposeWindow = should;
  278. }
  279.  
  280. inline ODBoolean CFrameInfo::ShouldDisposeWindow()
  281. {
  282.     return fShouldDisposeWindow;
  283. }
  284.  
  285. #endif
  286.  
  287.